Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Conversation

@spalmurray-codecov
Copy link
Contributor

Adds is_admin to account_details serializer. To be used for codecov/engineering-team#3201

@spalmurray-codecov spalmurray-codecov marked this pull request as ready for review January 28, 2025 22:43
@codecov-notifications
Copy link

codecov-notifications bot commented Jan 28, 2025

❌ 6 Tests Failed:

Tests completed Failed Passed Skipped
2710 6 2704 7
View the top 3 failed tests by shortest run time
api/internal/tests/views/test_account_viewset.py::AccountViewSetTests::test_retrieve_account_gets_account_fields
Stack Traces | 0.042s run time
self = <test_account_viewset.AccountViewSetTests testMethod=test_retrieve_account_gets_account_fields>

    def test_retrieve_account_gets_account_fields(self):
        owner = OwnerFactory(admins=[self.current_owner.ownerid])
        self.current_owner.organizations = [owner.ownerid]
        self.current_owner.save()
        response = self._retrieve(
            kwargs={"service": owner.service, "owner_username": owner.username}
        )
        assert response.status_code == status.HTTP_200_OK
>       assert response.data == {
            "activated_user_count": 0,
            "root_organization": None,
            "integration_id": owner.integration_id,
            "plan_auto_activate": owner.plan_auto_activate,
            "inactive_user_count": 1,
            "plan": {
                "marketing_name": "Developer",
                "value": PlanName.BASIC_PLAN_NAME.value,
                "billing_rate": None,
                "base_unit_price": 0,
                "benefits": [
                    "Up to 1 user",
                    "Unlimited public repositories",
                    "Unlimited private repositories",
                ],
                "quantity": 1,
            },
            "subscription_detail": None,
            "checkout_session_id": None,
            "name": owner.name,
            "email": owner.email,
            "nb_active_private_repos": 0,
            "repo_total_credits": 99999999,
            "plan_provider": owner.plan_provider,
            "activated_student_count": 0,
            "student_count": 0,
            "schedule_detail": None,
            "uses_invoice": False,
            "delinquent": None,
        }
E       AssertionError: assert {'integration..._admin': True} == {'activated_s...t': None, ...}
E         
E         Omitting 18 identical items, use -vv to show
E         Left contains 1 more item:
E         {'is_admin': True}
E         Use -v to get more diff

.../tests/views/test_account_viewset.py:153: AssertionError
api/internal/tests/views/test_account_viewset.py::AccountViewSetTests::test_retrieve_account_returns_last_phase_when_more_than_one_scheduled_phases
Stack Traces | 0.044s run time
self = <test_account_viewset.AccountViewSetTests testMethod=test_retrieve_account_returns_last_phase_when_more_than_one_scheduled_phases>
mock_retrieve_subscription = <MagicMock name='retrieve' id='140463642211104'>
mock_retrieve_schedule = <MagicMock name='retrieve' id='140463642931184'>

    @patch("services.billing.stripe.SubscriptionSchedule.retrieve")
    @patch("services.billing.stripe.Subscription.retrieve")
    def test_retrieve_account_returns_last_phase_when_more_than_one_scheduled_phases(
        self, mock_retrieve_subscription, mock_retrieve_schedule
    ):
        owner = OwnerFactory(
            admins=[self.current_owner.ownerid], stripe_subscription_id="sub_2345687"
        )
        self.current_owner.organizations = [owner.ownerid]
        self.current_owner.save()
    
        subscription_params = {
            "default_payment_method": None,
            "cancel_at_period_end": False,
            "current_period_end": 1633512445,
            "latest_invoice": None,
            "schedule_id": "sub_sched_456678999",
            "collection_method": "charge_automatically",
            "trial_end": 1633512445,
            "tax_ids": None,
        }
    
        mock_retrieve_subscription.return_value = MockSubscription(subscription_params)
        schedule_params = {
            "id": 123,
            "start_date": 123689126736,
            "stripe_plan_id": "plan_H6P3KZXwmAbqPS",
            "quantity": 6,
        }
        phases = [
            {
                "start_date": 123689126536,
                "items": [{"plan": "test_plan_123", "quantity": 4}],
            },
            {
                "start_date": 123689126636,
                "items": [{"plan": "test_plan_456", "quantity": 5}],
            },
            {
                "start_date": schedule_params["start_date"],
                "items": [
                    {
                        "plan": schedule_params["stripe_plan_id"],
                        "quantity": schedule_params["quantity"],
                    }
                ],
            },
        ]
    
        mock_retrieve_schedule.return_value = MockSchedule(schedule_params, phases)
    
        response = self._retrieve(
            kwargs={"service": owner.service, "owner_username": owner.username}
        )
        assert response.status_code == status.HTTP_200_OK
>       assert response.data == {
            "activated_user_count": 0,
            "root_organization": None,
            "integration_id": owner.integration_id,
            "plan_auto_activate": owner.plan_auto_activate,
            "inactive_user_count": 1,
            "plan": {
                "marketing_name": "Developer",
                "value": PlanName.BASIC_PLAN_NAME.value,
                "billing_rate": None,
                "base_unit_price": 0,
                "benefits": [
                    "Up to 1 user",
                    "Unlimited public repositories",
                    "Unlimited private repositories",
                ],
                "quantity": 1,
            },
            "subscription_detail": {
                "latest_invoice": None,
                "default_payment_method": None,
                "cancel_at_period_end": False,
                "current_period_end": 1633512445,
                "customer": {"id": "cus_LK&*Hli8YLIO", "discount": None, "email": None},
                "collection_method": "charge_automatically",
                "trial_end": 1633512445,
                "tax_ids": None,
            },
            "checkout_session_id": None,
            "name": owner.name,
            "email": owner.email,
            "nb_active_private_repos": 0,
            "repo_total_credits": 99999999,
            "plan_provider": owner.plan_provider,
            "activated_student_count": 0,
            "student_count": 0,
            "schedule_detail": {
                "id": "123",
                "scheduled_phase": {
                    "plan": "monthly",
                    "quantity": schedule_params["quantity"],
                    "start_date": schedule_params["start_date"],
                },
            },
            "uses_invoice": False,
            "delinquent": None,
        }
E       AssertionError: assert {'integration..._admin': True} == {'activated_s...t': None, ...}
E         
E         Omitting 18 identical items, use -vv to show
E         Left contains 1 more item:
E         {'is_admin': True}
E         Use -v to get more diff

.../tests/views/test_account_viewset.py:335: AssertionError
api/internal/tests/views/test_account_viewset.py::AccountViewSetTests::test_retrieve_account_gets_account_fields_when_there_are_scheduled_details
Stack Traces | 0.045s run time
self = <test_account_viewset.AccountViewSetTests testMethod=test_retrieve_account_gets_account_fields_when_there_are_scheduled_details>
mock_retrieve_subscription = <MagicMock name='retrieve' id='140463647291104'>
mock_retrieve_schedule = <MagicMock name='retrieve' id='140463641892128'>

    @patch("services.billing.stripe.SubscriptionSchedule.retrieve")
    @patch("services.billing.stripe.Subscription.retrieve")
    def test_retrieve_account_gets_account_fields_when_there_are_scheduled_details(
        self, mock_retrieve_subscription, mock_retrieve_schedule
    ):
        owner = OwnerFactory(
            admins=[self.current_owner.ownerid], stripe_subscription_id="sub_123"
        )
        self.current_owner.organizations = [owner.ownerid]
        self.current_owner.save()
    
        subscription_params = {
            "default_payment_method": None,
            "cancel_at_period_end": False,
            "current_period_end": 1633512445,
            "latest_invoice": None,
            "schedule_id": "sub_sched_456",
            "collection_method": "charge_automatically",
            "tax_ids": None,
        }
    
        mock_retrieve_subscription.return_value = MockSubscription(subscription_params)
        schedule_params = {
            "id": 123,
            "start_date": 123689126736,
            "stripe_plan_id": "plan_H6P3KZXwmAbqPS",
            "quantity": 6,
        }
        phases = [
            {},
            {
                "start_date": schedule_params["start_date"],
                "items": [
                    {
                        "plan": schedule_params["stripe_plan_id"],
                        "quantity": schedule_params["quantity"],
                    }
                ],
            },
        ]
    
        mock_retrieve_schedule.return_value = MockSchedule(schedule_params, phases)
    
        response = self._retrieve(
            kwargs={"service": owner.service, "owner_username": owner.username}
        )
        assert response.status_code == status.HTTP_200_OK
>       assert response.data == {
            "activated_user_count": 0,
            "root_organization": None,
            "integration_id": owner.integration_id,
            "plan_auto_activate": owner.plan_auto_activate,
            "inactive_user_count": 1,
            "plan": {
                "marketing_name": "Developer",
                "value": PlanName.BASIC_PLAN_NAME.value,
                "billing_rate": None,
                "base_unit_price": 0,
                "benefits": [
                    "Up to 1 user",
                    "Unlimited public repositories",
                    "Unlimited private repositories",
                ],
                "quantity": 1,
            },
            "subscription_detail": {
                "latest_invoice": None,
                "default_payment_method": None,
                "cancel_at_period_end": False,
                "current_period_end": 1633512445,
                "customer": {"id": "cus_LK&*Hli8YLIO", "discount": None, "email": None},
                "collection_method": "charge_automatically",
                "trial_end": None,
                "tax_ids": None,
            },
            "checkout_session_id": None,
            "name": owner.name,
            "email": owner.email,
            "nb_active_private_repos": 0,
            "repo_total_credits": 99999999,
            "plan_provider": owner.plan_provider,
            "activated_student_count": 0,
            "student_count": 0,
            "schedule_detail": {
                "id": "123",
                "scheduled_phase": {
                    "plan": "monthly",
                    "quantity": schedule_params["quantity"],
                    "start_date": schedule_params["start_date"],
                },
            },
            "uses_invoice": False,
            "delinquent": None,
        }
E       AssertionError: assert {'integration..._admin': True} == {'activated_s...t': None, ...}
E         
E         Omitting 18 identical items, use -vv to show
E         Left contains 1 more item:
E         {'is_admin': True}
E         Use -v to get more diff

.../tests/views/test_account_viewset.py:232: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

@codecov-qa
Copy link

codecov-qa bot commented Jan 28, 2025

❌ 6 Tests Failed:

Tests completed Failed Passed Skipped
2710 6 2704 7
View the top 3 failed tests by shortest run time
api/internal/tests/views/test_account_viewset.py::AccountViewSetTests::test_retrieve_account_gets_account_fields
Stack Traces | 0.042s run time
self = <test_account_viewset.AccountViewSetTests testMethod=test_retrieve_account_gets_account_fields>

    def test_retrieve_account_gets_account_fields(self):
        owner = OwnerFactory(admins=[self.current_owner.ownerid])
        self.current_owner.organizations = [owner.ownerid]
        self.current_owner.save()
        response = self._retrieve(
            kwargs={"service": owner.service, "owner_username": owner.username}
        )
        assert response.status_code == status.HTTP_200_OK
>       assert response.data == {
            "activated_user_count": 0,
            "root_organization": None,
            "integration_id": owner.integration_id,
            "plan_auto_activate": owner.plan_auto_activate,
            "inactive_user_count": 1,
            "plan": {
                "marketing_name": "Developer",
                "value": PlanName.BASIC_PLAN_NAME.value,
                "billing_rate": None,
                "base_unit_price": 0,
                "benefits": [
                    "Up to 1 user",
                    "Unlimited public repositories",
                    "Unlimited private repositories",
                ],
                "quantity": 1,
            },
            "subscription_detail": None,
            "checkout_session_id": None,
            "name": owner.name,
            "email": owner.email,
            "nb_active_private_repos": 0,
            "repo_total_credits": 99999999,
            "plan_provider": owner.plan_provider,
            "activated_student_count": 0,
            "student_count": 0,
            "schedule_detail": None,
            "uses_invoice": False,
            "delinquent": None,
        }
E       AssertionError: assert {'integration..._admin': True} == {'activated_s...t': None, ...}
E         
E         Omitting 18 identical items, use -vv to show
E         Left contains 1 more item:
E         {'is_admin': True}
E         Use -v to get more diff

.../tests/views/test_account_viewset.py:153: AssertionError
api/internal/tests/views/test_account_viewset.py::AccountViewSetTests::test_retrieve_account_returns_last_phase_when_more_than_one_scheduled_phases
Stack Traces | 0.044s run time
self = <test_account_viewset.AccountViewSetTests testMethod=test_retrieve_account_returns_last_phase_when_more_than_one_scheduled_phases>
mock_retrieve_subscription = <MagicMock name='retrieve' id='140463642211104'>
mock_retrieve_schedule = <MagicMock name='retrieve' id='140463642931184'>

    @patch("services.billing.stripe.SubscriptionSchedule.retrieve")
    @patch("services.billing.stripe.Subscription.retrieve")
    def test_retrieve_account_returns_last_phase_when_more_than_one_scheduled_phases(
        self, mock_retrieve_subscription, mock_retrieve_schedule
    ):
        owner = OwnerFactory(
            admins=[self.current_owner.ownerid], stripe_subscription_id="sub_2345687"
        )
        self.current_owner.organizations = [owner.ownerid]
        self.current_owner.save()
    
        subscription_params = {
            "default_payment_method": None,
            "cancel_at_period_end": False,
            "current_period_end": 1633512445,
            "latest_invoice": None,
            "schedule_id": "sub_sched_456678999",
            "collection_method": "charge_automatically",
            "trial_end": 1633512445,
            "tax_ids": None,
        }
    
        mock_retrieve_subscription.return_value = MockSubscription(subscription_params)
        schedule_params = {
            "id": 123,
            "start_date": 123689126736,
            "stripe_plan_id": "plan_H6P3KZXwmAbqPS",
            "quantity": 6,
        }
        phases = [
            {
                "start_date": 123689126536,
                "items": [{"plan": "test_plan_123", "quantity": 4}],
            },
            {
                "start_date": 123689126636,
                "items": [{"plan": "test_plan_456", "quantity": 5}],
            },
            {
                "start_date": schedule_params["start_date"],
                "items": [
                    {
                        "plan": schedule_params["stripe_plan_id"],
                        "quantity": schedule_params["quantity"],
                    }
                ],
            },
        ]
    
        mock_retrieve_schedule.return_value = MockSchedule(schedule_params, phases)
    
        response = self._retrieve(
            kwargs={"service": owner.service, "owner_username": owner.username}
        )
        assert response.status_code == status.HTTP_200_OK
>       assert response.data == {
            "activated_user_count": 0,
            "root_organization": None,
            "integration_id": owner.integration_id,
            "plan_auto_activate": owner.plan_auto_activate,
            "inactive_user_count": 1,
            "plan": {
                "marketing_name": "Developer",
                "value": PlanName.BASIC_PLAN_NAME.value,
                "billing_rate": None,
                "base_unit_price": 0,
                "benefits": [
                    "Up to 1 user",
                    "Unlimited public repositories",
                    "Unlimited private repositories",
                ],
                "quantity": 1,
            },
            "subscription_detail": {
                "latest_invoice": None,
                "default_payment_method": None,
                "cancel_at_period_end": False,
                "current_period_end": 1633512445,
                "customer": {"id": "cus_LK&*Hli8YLIO", "discount": None, "email": None},
                "collection_method": "charge_automatically",
                "trial_end": 1633512445,
                "tax_ids": None,
            },
            "checkout_session_id": None,
            "name": owner.name,
            "email": owner.email,
            "nb_active_private_repos": 0,
            "repo_total_credits": 99999999,
            "plan_provider": owner.plan_provider,
            "activated_student_count": 0,
            "student_count": 0,
            "schedule_detail": {
                "id": "123",
                "scheduled_phase": {
                    "plan": "monthly",
                    "quantity": schedule_params["quantity"],
                    "start_date": schedule_params["start_date"],
                },
            },
            "uses_invoice": False,
            "delinquent": None,
        }
E       AssertionError: assert {'integration..._admin': True} == {'activated_s...t': None, ...}
E         
E         Omitting 18 identical items, use -vv to show
E         Left contains 1 more item:
E         {'is_admin': True}
E         Use -v to get more diff

.../tests/views/test_account_viewset.py:335: AssertionError
api/internal/tests/views/test_account_viewset.py::AccountViewSetTests::test_retrieve_account_gets_account_fields_when_there_are_scheduled_details
Stack Traces | 0.045s run time
self = <test_account_viewset.AccountViewSetTests testMethod=test_retrieve_account_gets_account_fields_when_there_are_scheduled_details>
mock_retrieve_subscription = <MagicMock name='retrieve' id='140463647291104'>
mock_retrieve_schedule = <MagicMock name='retrieve' id='140463641892128'>

    @patch("services.billing.stripe.SubscriptionSchedule.retrieve")
    @patch("services.billing.stripe.Subscription.retrieve")
    def test_retrieve_account_gets_account_fields_when_there_are_scheduled_details(
        self, mock_retrieve_subscription, mock_retrieve_schedule
    ):
        owner = OwnerFactory(
            admins=[self.current_owner.ownerid], stripe_subscription_id="sub_123"
        )
        self.current_owner.organizations = [owner.ownerid]
        self.current_owner.save()
    
        subscription_params = {
            "default_payment_method": None,
            "cancel_at_period_end": False,
            "current_period_end": 1633512445,
            "latest_invoice": None,
            "schedule_id": "sub_sched_456",
            "collection_method": "charge_automatically",
            "tax_ids": None,
        }
    
        mock_retrieve_subscription.return_value = MockSubscription(subscription_params)
        schedule_params = {
            "id": 123,
            "start_date": 123689126736,
            "stripe_plan_id": "plan_H6P3KZXwmAbqPS",
            "quantity": 6,
        }
        phases = [
            {},
            {
                "start_date": schedule_params["start_date"],
                "items": [
                    {
                        "plan": schedule_params["stripe_plan_id"],
                        "quantity": schedule_params["quantity"],
                    }
                ],
            },
        ]
    
        mock_retrieve_schedule.return_value = MockSchedule(schedule_params, phases)
    
        response = self._retrieve(
            kwargs={"service": owner.service, "owner_username": owner.username}
        )
        assert response.status_code == status.HTTP_200_OK
>       assert response.data == {
            "activated_user_count": 0,
            "root_organization": None,
            "integration_id": owner.integration_id,
            "plan_auto_activate": owner.plan_auto_activate,
            "inactive_user_count": 1,
            "plan": {
                "marketing_name": "Developer",
                "value": PlanName.BASIC_PLAN_NAME.value,
                "billing_rate": None,
                "base_unit_price": 0,
                "benefits": [
                    "Up to 1 user",
                    "Unlimited public repositories",
                    "Unlimited private repositories",
                ],
                "quantity": 1,
            },
            "subscription_detail": {
                "latest_invoice": None,
                "default_payment_method": None,
                "cancel_at_period_end": False,
                "current_period_end": 1633512445,
                "customer": {"id": "cus_LK&*Hli8YLIO", "discount": None, "email": None},
                "collection_method": "charge_automatically",
                "trial_end": None,
                "tax_ids": None,
            },
            "checkout_session_id": None,
            "name": owner.name,
            "email": owner.email,
            "nb_active_private_repos": 0,
            "repo_total_credits": 99999999,
            "plan_provider": owner.plan_provider,
            "activated_student_count": 0,
            "student_count": 0,
            "schedule_detail": {
                "id": "123",
                "scheduled_phase": {
                    "plan": "monthly",
                    "quantity": schedule_params["quantity"],
                    "start_date": schedule_params["start_date"],
                },
            },
            "uses_invoice": False,
            "delinquent": None,
        }
E       AssertionError: assert {'integration..._admin': True} == {'activated_s...t': None, ...}
E         
E         Omitting 18 identical items, use -vv to show
E         Left contains 1 more item:
E         {'is_admin': True}
E         Use -v to get more diff

.../tests/views/test_account_viewset.py:232: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

@codecov-public-qa
Copy link

❌ 6 Tests Failed:

Tests completed Failed Passed Skipped
2711 6 2705 6
View the top 3 failed tests by shortest run time
api/internal/tests/views/test_account_viewset.py::AccountViewSetTests::test_retrieve_account_gets_account_fields
Stack Traces | 0.042s run time
self = <test_account_viewset.AccountViewSetTests testMethod=test_retrieve_account_gets_account_fields>

    def test_retrieve_account_gets_account_fields(self):
        owner = OwnerFactory(admins=[self.current_owner.ownerid])
        self.current_owner.organizations = [owner.ownerid]
        self.current_owner.save()
        response = self._retrieve(
            kwargs={"service": owner.service, "owner_username": owner.username}
        )
        assert response.status_code == status.HTTP_200_OK
>       assert response.data == {
            "activated_user_count": 0,
            "root_organization": None,
            "integration_id": owner.integration_id,
            "plan_auto_activate": owner.plan_auto_activate,
            "inactive_user_count": 1,
            "plan": {
                "marketing_name": "Developer",
                "value": PlanName.BASIC_PLAN_NAME.value,
                "billing_rate": None,
                "base_unit_price": 0,
                "benefits": [
                    "Up to 1 user",
                    "Unlimited public repositories",
                    "Unlimited private repositories",
                ],
                "quantity": 1,
            },
            "subscription_detail": None,
            "checkout_session_id": None,
            "name": owner.name,
            "email": owner.email,
            "nb_active_private_repos": 0,
            "repo_total_credits": 99999999,
            "plan_provider": owner.plan_provider,
            "activated_student_count": 0,
            "student_count": 0,
            "schedule_detail": None,
            "uses_invoice": False,
            "delinquent": None,
        }
E       AssertionError: assert {'integration..._admin': True} == {'activated_s...t': None, ...}
E         
E         Omitting 18 identical items, use -vv to show
E         Left contains 1 more item:
E         {'is_admin': True}
E         Use -v to get more diff

.../tests/views/test_account_viewset.py:153: AssertionError
api/internal/tests/views/test_account_viewset.py::AccountViewSetTests::test_retrieve_account_returns_last_phase_when_more_than_one_scheduled_phases
Stack Traces | 0.044s run time
self = <test_account_viewset.AccountViewSetTests testMethod=test_retrieve_account_returns_last_phase_when_more_than_one_scheduled_phases>
mock_retrieve_subscription = <MagicMock name='retrieve' id='140463642211104'>
mock_retrieve_schedule = <MagicMock name='retrieve' id='140463642931184'>

    @patch("services.billing.stripe.SubscriptionSchedule.retrieve")
    @patch("services.billing.stripe.Subscription.retrieve")
    def test_retrieve_account_returns_last_phase_when_more_than_one_scheduled_phases(
        self, mock_retrieve_subscription, mock_retrieve_schedule
    ):
        owner = OwnerFactory(
            admins=[self.current_owner.ownerid], stripe_subscription_id="sub_2345687"
        )
        self.current_owner.organizations = [owner.ownerid]
        self.current_owner.save()
    
        subscription_params = {
            "default_payment_method": None,
            "cancel_at_period_end": False,
            "current_period_end": 1633512445,
            "latest_invoice": None,
            "schedule_id": "sub_sched_456678999",
            "collection_method": "charge_automatically",
            "trial_end": 1633512445,
            "tax_ids": None,
        }
    
        mock_retrieve_subscription.return_value = MockSubscription(subscription_params)
        schedule_params = {
            "id": 123,
            "start_date": 123689126736,
            "stripe_plan_id": "plan_H6P3KZXwmAbqPS",
            "quantity": 6,
        }
        phases = [
            {
                "start_date": 123689126536,
                "items": [{"plan": "test_plan_123", "quantity": 4}],
            },
            {
                "start_date": 123689126636,
                "items": [{"plan": "test_plan_456", "quantity": 5}],
            },
            {
                "start_date": schedule_params["start_date"],
                "items": [
                    {
                        "plan": schedule_params["stripe_plan_id"],
                        "quantity": schedule_params["quantity"],
                    }
                ],
            },
        ]
    
        mock_retrieve_schedule.return_value = MockSchedule(schedule_params, phases)
    
        response = self._retrieve(
            kwargs={"service": owner.service, "owner_username": owner.username}
        )
        assert response.status_code == status.HTTP_200_OK
>       assert response.data == {
            "activated_user_count": 0,
            "root_organization": None,
            "integration_id": owner.integration_id,
            "plan_auto_activate": owner.plan_auto_activate,
            "inactive_user_count": 1,
            "plan": {
                "marketing_name": "Developer",
                "value": PlanName.BASIC_PLAN_NAME.value,
                "billing_rate": None,
                "base_unit_price": 0,
                "benefits": [
                    "Up to 1 user",
                    "Unlimited public repositories",
                    "Unlimited private repositories",
                ],
                "quantity": 1,
            },
            "subscription_detail": {
                "latest_invoice": None,
                "default_payment_method": None,
                "cancel_at_period_end": False,
                "current_period_end": 1633512445,
                "customer": {"id": "cus_LK&*Hli8YLIO", "discount": None, "email": None},
                "collection_method": "charge_automatically",
                "trial_end": 1633512445,
                "tax_ids": None,
            },
            "checkout_session_id": None,
            "name": owner.name,
            "email": owner.email,
            "nb_active_private_repos": 0,
            "repo_total_credits": 99999999,
            "plan_provider": owner.plan_provider,
            "activated_student_count": 0,
            "student_count": 0,
            "schedule_detail": {
                "id": "123",
                "scheduled_phase": {
                    "plan": "monthly",
                    "quantity": schedule_params["quantity"],
                    "start_date": schedule_params["start_date"],
                },
            },
            "uses_invoice": False,
            "delinquent": None,
        }
E       AssertionError: assert {'integration..._admin': True} == {'activated_s...t': None, ...}
E         
E         Omitting 18 identical items, use -vv to show
E         Left contains 1 more item:
E         {'is_admin': True}
E         Use -v to get more diff

.../tests/views/test_account_viewset.py:335: AssertionError
api/internal/tests/views/test_account_viewset.py::AccountViewSetTests::test_retrieve_account_gets_account_fields_when_there_are_scheduled_details
Stack Traces | 0.045s run time
self = <test_account_viewset.AccountViewSetTests testMethod=test_retrieve_account_gets_account_fields_when_there_are_scheduled_details>
mock_retrieve_subscription = <MagicMock name='retrieve' id='140463647291104'>
mock_retrieve_schedule = <MagicMock name='retrieve' id='140463641892128'>

    @patch("services.billing.stripe.SubscriptionSchedule.retrieve")
    @patch("services.billing.stripe.Subscription.retrieve")
    def test_retrieve_account_gets_account_fields_when_there_are_scheduled_details(
        self, mock_retrieve_subscription, mock_retrieve_schedule
    ):
        owner = OwnerFactory(
            admins=[self.current_owner.ownerid], stripe_subscription_id="sub_123"
        )
        self.current_owner.organizations = [owner.ownerid]
        self.current_owner.save()
    
        subscription_params = {
            "default_payment_method": None,
            "cancel_at_period_end": False,
            "current_period_end": 1633512445,
            "latest_invoice": None,
            "schedule_id": "sub_sched_456",
            "collection_method": "charge_automatically",
            "tax_ids": None,
        }
    
        mock_retrieve_subscription.return_value = MockSubscription(subscription_params)
        schedule_params = {
            "id": 123,
            "start_date": 123689126736,
            "stripe_plan_id": "plan_H6P3KZXwmAbqPS",
            "quantity": 6,
        }
        phases = [
            {},
            {
                "start_date": schedule_params["start_date"],
                "items": [
                    {
                        "plan": schedule_params["stripe_plan_id"],
                        "quantity": schedule_params["quantity"],
                    }
                ],
            },
        ]
    
        mock_retrieve_schedule.return_value = MockSchedule(schedule_params, phases)
    
        response = self._retrieve(
            kwargs={"service": owner.service, "owner_username": owner.username}
        )
        assert response.status_code == status.HTTP_200_OK
>       assert response.data == {
            "activated_user_count": 0,
            "root_organization": None,
            "integration_id": owner.integration_id,
            "plan_auto_activate": owner.plan_auto_activate,
            "inactive_user_count": 1,
            "plan": {
                "marketing_name": "Developer",
                "value": PlanName.BASIC_PLAN_NAME.value,
                "billing_rate": None,
                "base_unit_price": 0,
                "benefits": [
                    "Up to 1 user",
                    "Unlimited public repositories",
                    "Unlimited private repositories",
                ],
                "quantity": 1,
            },
            "subscription_detail": {
                "latest_invoice": None,
                "default_payment_method": None,
                "cancel_at_period_end": False,
                "current_period_end": 1633512445,
                "customer": {"id": "cus_LK&*Hli8YLIO", "discount": None, "email": None},
                "collection_method": "charge_automatically",
                "trial_end": None,
                "tax_ids": None,
            },
            "checkout_session_id": None,
            "name": owner.name,
            "email": owner.email,
            "nb_active_private_repos": 0,
            "repo_total_credits": 99999999,
            "plan_provider": owner.plan_provider,
            "activated_student_count": 0,
            "student_count": 0,
            "schedule_detail": {
                "id": "123",
                "scheduled_phase": {
                    "plan": "monthly",
                    "quantity": schedule_params["quantity"],
                    "start_date": schedule_params["start_date"],
                },
            },
            "uses_invoice": False,
            "delinquent": None,
        }
E       AssertionError: assert {'integration..._admin': True} == {'activated_s...t': None, ...}
E         
E         Omitting 18 identical items, use -vv to show
E         Left contains 1 more item:
E         {'is_admin': True}
E         Use -v to get more diff

.../tests/views/test_account_viewset.py:232: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Contributor

❌ 6 Tests Failed:

Tests completed Failed Passed Skipped
2717 6 2705 6
View the top 3 failed tests by shortest run time
test_retrieve_account_gets_account_fields
Stack Traces | 0.042s run time
self = &lt;test_account_viewset.AccountViewSetTests testMethod=test_retrieve_account_gets_account_fields&gt;

    def test_retrieve_account_gets_account_fields(self):
        owner = OwnerFactory(admins=[self.current_owner.ownerid])
        self.current_owner.organizations = [owner.ownerid]
        self.current_owner.save()
        response = self._retrieve(
            kwargs={"service": owner.service, "owner_username": owner.username}
        )
        assert response.status_code == status.HTTP_200_OK
&gt;       assert response.data == {
            "activated_user_count": 0,
            "root_organization": None,
            "integration_id": owner.integration_id,
            "plan_auto_activate": owner.plan_auto_activate,
            "inactive_user_count": 1,
            "plan": {
                "marketing_name": "Developer",
                "value": PlanName.BASIC_PLAN_NAME.value,
                "billing_rate": None,
                "base_unit_price": 0,
                "benefits": [
                    "Up to 1 user",
                    "Unlimited public repositories",
                    "Unlimited private repositories",
                ],
                "quantity": 1,
            },
            "subscription_detail": None,
            "checkout_session_id": None,
            "name": owner.name,
            "email": owner.email,
            "nb_active_private_repos": 0,
            "repo_total_credits": 99999999,
            "plan_provider": owner.plan_provider,
            "activated_student_count": 0,
            "student_count": 0,
            "schedule_detail": None,
            "uses_invoice": False,
            "delinquent": None,
        }
E       AssertionError: assert {'integration..._admin': True} == {'activated_s...t': None, ...}
E         
E         Omitting 18 identical items, use -vv to show
E         Left contains 1 more item:
E         {'is_admin': True}
E         Use -v to get more diff

api/internal/tests/views/test_account_viewset.py:153: AssertionError
test_retrieve_account_returns_last_phase_when_more_than_one_scheduled_phases
Stack Traces | 0.044s run time
self = &lt;test_account_viewset.AccountViewSetTests testMethod=test_retrieve_account_returns_last_phase_when_more_than_one_scheduled_phases&gt;
mock_retrieve_subscription = &lt;MagicMock name='retrieve' id='140463642211104'&gt;
mock_retrieve_schedule = &lt;MagicMock name='retrieve' id='140463642931184'&gt;

    @patch("services.billing.stripe.SubscriptionSchedule.retrieve")
    @patch("services.billing.stripe.Subscription.retrieve")
    def test_retrieve_account_returns_last_phase_when_more_than_one_scheduled_phases(
        self, mock_retrieve_subscription, mock_retrieve_schedule
    ):
        owner = OwnerFactory(
            admins=[self.current_owner.ownerid], stripe_subscription_id="sub_2345687"
        )
        self.current_owner.organizations = [owner.ownerid]
        self.current_owner.save()
    
        subscription_params = {
            "default_payment_method": None,
            "cancel_at_period_end": False,
            "current_period_end": 1633512445,
            "latest_invoice": None,
            "schedule_id": "sub_sched_456678999",
            "collection_method": "charge_automatically",
            "trial_end": 1633512445,
            "tax_ids": None,
        }
    
        mock_retrieve_subscription.return_value = MockSubscription(subscription_params)
        schedule_params = {
            "id": 123,
            "start_date": 123689126736,
            "stripe_plan_id": "plan_H6P3KZXwmAbqPS",
            "quantity": 6,
        }
        phases = [
            {
                "start_date": 123689126536,
                "items": [{"plan": "test_plan_123", "quantity": 4}],
            },
            {
                "start_date": 123689126636,
                "items": [{"plan": "test_plan_456", "quantity": 5}],
            },
            {
                "start_date": schedule_params["start_date"],
                "items": [
                    {
                        "plan": schedule_params["stripe_plan_id"],
                        "quantity": schedule_params["quantity"],
                    }
                ],
            },
        ]
    
        mock_retrieve_schedule.return_value = MockSchedule(schedule_params, phases)
    
        response = self._retrieve(
            kwargs={"service": owner.service, "owner_username": owner.username}
        )
        assert response.status_code == status.HTTP_200_OK
&gt;       assert response.data == {
            "activated_user_count": 0,
            "root_organization": None,
            "integration_id": owner.integration_id,
            "plan_auto_activate": owner.plan_auto_activate,
            "inactive_user_count": 1,
            "plan": {
                "marketing_name": "Developer",
                "value": PlanName.BASIC_PLAN_NAME.value,
                "billing_rate": None,
                "base_unit_price": 0,
                "benefits": [
                    "Up to 1 user",
                    "Unlimited public repositories",
                    "Unlimited private repositories",
                ],
                "quantity": 1,
            },
            "subscription_detail": {
                "latest_invoice": None,
                "default_payment_method": None,
                "cancel_at_period_end": False,
                "current_period_end": 1633512445,
                "customer": {"id": "cus_LK&amp;*Hli8YLIO", "discount": None, "email": None},
                "collection_method": "charge_automatically",
                "trial_end": 1633512445,
                "tax_ids": None,
            },
            "checkout_session_id": None,
            "name": owner.name,
            "email": owner.email,
            "nb_active_private_repos": 0,
            "repo_total_credits": 99999999,
            "plan_provider": owner.plan_provider,
            "activated_student_count": 0,
            "student_count": 0,
            "schedule_detail": {
                "id": "123",
                "scheduled_phase": {
                    "plan": "monthly",
                    "quantity": schedule_params["quantity"],
                    "start_date": schedule_params["start_date"],
                },
            },
            "uses_invoice": False,
            "delinquent": None,
        }
E       AssertionError: assert {'integration..._admin': True} == {'activated_s...t': None, ...}
E         
E         Omitting 18 identical items, use -vv to show
E         Left contains 1 more item:
E         {'is_admin': True}
E         Use -v to get more diff

api/internal/tests/views/test_account_viewset.py:335: AssertionError
test_retrieve_account_gets_account_fields_when_there_are_scheduled_details
Stack Traces | 0.045s run time
self = &lt;test_account_viewset.AccountViewSetTests testMethod=test_retrieve_account_gets_account_fields_when_there_are_scheduled_details&gt;
mock_retrieve_subscription = &lt;MagicMock name='retrieve' id='140463647291104'&gt;
mock_retrieve_schedule = &lt;MagicMock name='retrieve' id='140463641892128'&gt;

    @patch("services.billing.stripe.SubscriptionSchedule.retrieve")
    @patch("services.billing.stripe.Subscription.retrieve")
    def test_retrieve_account_gets_account_fields_when_there_are_scheduled_details(
        self, mock_retrieve_subscription, mock_retrieve_schedule
    ):
        owner = OwnerFactory(
            admins=[self.current_owner.ownerid], stripe_subscription_id="sub_123"
        )
        self.current_owner.organizations = [owner.ownerid]
        self.current_owner.save()
    
        subscription_params = {
            "default_payment_method": None,
            "cancel_at_period_end": False,
            "current_period_end": 1633512445,
            "latest_invoice": None,
            "schedule_id": "sub_sched_456",
            "collection_method": "charge_automatically",
            "tax_ids": None,
        }
    
        mock_retrieve_subscription.return_value = MockSubscription(subscription_params)
        schedule_params = {
            "id": 123,
            "start_date": 123689126736,
            "stripe_plan_id": "plan_H6P3KZXwmAbqPS",
            "quantity": 6,
        }
        phases = [
            {},
            {
                "start_date": schedule_params["start_date"],
                "items": [
                    {
                        "plan": schedule_params["stripe_plan_id"],
                        "quantity": schedule_params["quantity"],
                    }
                ],
            },
        ]
    
        mock_retrieve_schedule.return_value = MockSchedule(schedule_params, phases)
    
        response = self._retrieve(
            kwargs={"service": owner.service, "owner_username": owner.username}
        )
        assert response.status_code == status.HTTP_200_OK
&gt;       assert response.data == {
            "activated_user_count": 0,
            "root_organization": None,
            "integration_id": owner.integration_id,
            "plan_auto_activate": owner.plan_auto_activate,
            "inactive_user_count": 1,
            "plan": {
                "marketing_name": "Developer",
                "value": PlanName.BASIC_PLAN_NAME.value,
                "billing_rate": None,
                "base_unit_price": 0,
                "benefits": [
                    "Up to 1 user",
                    "Unlimited public repositories",
                    "Unlimited private repositories",
                ],
                "quantity": 1,
            },
            "subscription_detail": {
                "latest_invoice": None,
                "default_payment_method": None,
                "cancel_at_period_end": False,
                "current_period_end": 1633512445,
                "customer": {"id": "cus_LK&amp;*Hli8YLIO", "discount": None, "email": None},
                "collection_method": "charge_automatically",
                "trial_end": None,
                "tax_ids": None,
            },
            "checkout_session_id": None,
            "name": owner.name,
            "email": owner.email,
            "nb_active_private_repos": 0,
            "repo_total_credits": 99999999,
            "plan_provider": owner.plan_provider,
            "activated_student_count": 0,
            "student_count": 0,
            "schedule_detail": {
                "id": "123",
                "scheduled_phase": {
                    "plan": "monthly",
                    "quantity": schedule_params["quantity"],
                    "start_date": schedule_params["start_date"],
                },
            },
            "uses_invoice": False,
            "delinquent": None,
        }
E       AssertionError: assert {'integration..._admin': True} == {'activated_s...t': None, ...}
E         
E         Omitting 18 identical items, use -vv to show
E         Left contains 1 more item:
E         {'is_admin': True}
E         Use -v to get more diff

api/internal/tests/views/test_account_viewset.py:232: AssertionError

📣 Thoughts on this report? Let Codecov know! | Powered by Codecov

@spalmurray-codecov
Copy link
Contributor Author

Closing as we want to deprecate this endpoint, would prefer to use GQL.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants